package com.itheima.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class MyResponseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> MyResponseResult<T> ok(T data){
        return MyResponseResult.<T>builder().code(1).data(data).msg("ok").build();
    }
    public static <T> MyResponseResult<T> ok(Integer code,String msg,T data){
        return MyResponseResult.<T>builder().code(code).data(data).msg(msg).build();
    }
    public static <T> MyResponseResult<T> error(String msg){
        return MyResponseResult.<T>builder().code(0).data(null).msg(msg).build();
    }
    public static <T> MyResponseResult<T> error(Integer code,String msg,T data){
        return MyResponseResult.<T>builder().code(code).data(data).msg(msg).build();
    }

}
